package com.tanhua.controller;

import com.tanhua.server.BaiduService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
/**
* @ClassName: com.tanhua.controller.BaiduController
* @Description:
* @author: Li
* @date: 2021/9/26 17:59
*/

@RestController
@RequestMapping("/baidu")
public class BaiduController {
    @Autowired
    private BaiduService baiduService;

    @PostMapping("/location")
    public ResponseEntity<List<Void>> updateLocation(@RequestBody Map map) {
        //纬度
        String latitude = map.get("latitude").toString();
        //经度
        String longitude = map.get("longitude").toString();
        //address
        String address = map.get("addrStr").toString();
        baiduService.updateOrSave(longitude, latitude, address);
        return ResponseEntity.ok(null);
    }
}
